import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

/**
 * 称砝码
 * 现有n种砝码，重量互不相等，分别为 m1,m2,m3…mn ；
 * 每种砝码对应的数量为 x1,x2,x3...xn 。现在要用这些砝码去称物体的重量(放在同一侧)，问能称出多少种不同的重量。
 * 注：
 * 称重重量包括 0
 */
public class HJ41 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int num = scanner.nextInt();
            int[] weight = new int[num];
            int[] nums = new int[num];
            for (int i = 0; i < num; i++) {
                weight[i] = scanner.nextInt();
            }
            for (int i = 0; i < num; i++) {
                nums[i] = scanner.nextInt();
            }

            HashSet<Integer> set = new HashSet<>();
            set.add(0);
            for (int i = 0; i < weight.length; i++) {
                ArrayList<Integer> list = new ArrayList<>(set);
                for (int j = 1; j <= nums[i]; j++) {
                    for (Integer n : list) {
                        set.add(n+weight[i]*j);
                    }
                }
            }
            System.out.println(set.size());
        }
    }
}
